﻿/*文件注释
 * ===============================================================================
 * 说明：
 * 作者：曾永佑
 * 版本：V1.0
 * 创建日期：2013-02-28
 * 完成日期： 
 * 修改纪录：  
 * ===============================================================================
 */  
        
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web; 
using System.Web.Mvc;
using System.Reflection;
using System.ComponentModel.DataAnnotations;
using System;

namespace SRF.UI.Html
{
    public static class TitleExtensions
    {
        /// <summary>
        /// 应用程序标题
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <returns></returns>
        public static MvcHtmlString AppTitle(this HtmlHelper htmlHelper)
        {
            var title = "";
            if (MvcSiteMapProvider.SiteMaps.Current != null)
            {
                title = MvcSiteMapProvider.SiteMaps.Current.RootNode.Title;
            }

            return new MvcHtmlString(title);
        }
        /// <summary>
        /// 当前页标题
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <returns></returns>
        public static MvcHtmlString PageTitle(this HtmlHelper htmlHelper)
        {
            var title = "";
            if (htmlHelper.ViewData["title"] != null)
            {
                title = htmlHelper.ViewData["title"].ToString();
            }
            else if (MvcSiteMapProvider.SiteMaps.Current.CurrentNode != null)
            {
                title = MvcSiteMapProvider.SiteMaps.Current.CurrentNode.Title;
            }

            return new MvcHtmlString(title);
        }  
    }
}